package com.vr.xuecheng.search.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author hzh
 * @date 2025/03/22
 * 课程索引
 */
@Document(indexName = "course-publish")
@Data
public class CourseIndex implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    @Id
    private Long id;
    @Field(type = FieldType.Keyword)
    private String charge;
    @Field(type = FieldType.Keyword)
    private Long companyId;
    @Field(type = FieldType.Text,
            analyzer = "ik_max_word",
            searchAnalyzer = "ik_smart")
    private String companyName;
    @Field(
            type = FieldType.Date,
            format = DateFormat.custom,
            pattern = "yyyy-MM-dd HH:mm:ss"
    )
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createDate;

    @Field(
            type = FieldType.Text,
            analyzer = "ik_max_word",
            searchAnalyzer = "ik_smart"
    )
    private String description;

    @Field(type = FieldType.Keyword)
    private String grade;

    @Field(type = FieldType.Keyword)
    private String mt;

    @Field(type = FieldType.Keyword)
    private String mtName;

    @Field(
            type = FieldType.Text,
            analyzer = "ik_max_word",
            searchAnalyzer = "ik_smart"
    )
    private String name;

    @Field(type = FieldType.Scaled_Float, scalingFactor = 100)
    private BigDecimal originalPrice;

    @Field(type = FieldType.Text, index = false)
    private String pic;

    @Field(type = FieldType.Scaled_Float, scalingFactor = 100)
    private BigDecimal price;

    @Field(type = FieldType.Text, index = false)
    private String remark;

    @Field(type = FieldType.Keyword)
    private String st;

    @Field(type = FieldType.Keyword)
    private String stName;

    @Field(type = FieldType.Keyword)
    private String status;

    @Field(
            type = FieldType.Text,
            analyzer = "ik_max_word",
            searchAnalyzer = "ik_smart"
    )
    private String tags;

    @Field(type = FieldType.Keyword)
    private String teachmode;

    @Field(type = FieldType.Text, index = false)
    private String users;

    @Field(type = FieldType.Integer)
    private Integer validDays;
}
